//
//  HomeCarouseWebVC.m
//  Tour
//
//  Created by hesiyao on 16/3/9.
//  Copyright © 2016年 张中烨. All rights reserved.
//

#import "HomeCarouseWebVC.h"

@interface HomeCarouseWebVC () <UIWebViewDelegate>

@end

@implementation HomeCarouseWebVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)forBarMetrics:UIBarMetricsDefault];//导航条返回键带的首页 让他消失
    
    /**< 设置导航栏标题 */
    self.navigationItem.title = @"详情";
    
    UIWebView *wv = [[UIWebView alloc]initWithFrame:self.view.bounds];
    /**< 自适应边界 */
    self.automaticallyAdjustsScrollViewInsets = YES;
    wv.scrollView.bounces = NO;

    [self.view addSubview:wv];
    [MBProgressHUDManager showHUDtoView:wv string:@"正在加载中..."];
    
    // js
    wv.scalesPageToFit = YES;
    wv.delegate = self;
    NSURL *url = [[NSURL alloc]initWithString:self.urlstr];
    NSURLRequest *request =  [[NSURLRequest alloc] initWithURL:url];
    [wv loadRequest:request];
    [MBProgressHUDManager removeHUD];
    
    self.navigationItem.rightBarButtonItem.enabled = NO;

    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    
    [wv NightWithType:UIViewColorTypeNormal];
}
/**<  web失去响应方式*/
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        return NO;
    }else{
        return YES;
    }
}
- (void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
